module DevicesHelper
  def fields_for_device_feature(device_feature, &block)
  prefix = device_feature.new_record? ? 'new' : 'existing'
  fields_for("device[#{prefix}_device_feature_attributes][]", device_feature, &block)
end

def add_device_feature_link(name) 
  link_to_function name do |page| 
    page.insert_html :bottom, :device_features, :partial => 'device_feature', :object => DeviceFeature.new 
  end 
end
end
